﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace BMSPlatform.Converter
{
    public class CANConnectedEnableConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int i;
            //value→CAN链接成功：true
            if(value is bool b && parameter is string str && int.TryParse(str, out i))
            {
                switch (i)
                {
                    case 0://CAN链接按钮
                        return b ? false : true;
                    case 1://CAN关闭设备按钮
                        return b ? true : false;
                }
                
            }
            return true;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
